<template>
	<view>
		<u-navbar :z-index="10" title="提现记录" :background="{
			background:'#ffc300'
		}">
			<template #right>
				<u-icon size="32" @click="search = true" class="u-m-r-14" name="search"></u-icon>
			</template>
		</u-navbar>

		<view v-for="(item,index) in list" :key="index" class="u-p-24 u-p-t-48 u-p-b-48 bg-white  u-font-24 u-flex list u-col-top u-border-bottom u-flex-wrap">
		    <u-image src="@/static/images/my/tx.png" width="60" height="60"></u-image>
			<view class="u-flex-1 u-p-l-32 u-p-r-32" style="overflow: hidden;">
				<view class="u-font-30 fw-large">{{enumIndex.cashState[item.cashState]}}</view>
				<view class="u-font-24 u-p-t-10 u-p-b-8" v-if="item.insideRemark">{{item.insideRemark}}</view>
				<view class="u-font-28 color-gary-xs u-p-t-12">{{item.businessName||item.fullName}}</view>
			</view>
			<text class="u-font-lg fw-large ">+{{item.amount}}</text>
			<view class="bottom">
				 <view>
					提现时间：{{item.createDate||""}}
				  </view>
				  <view>
					到账时间：{{item.completeDate||""}}
				  </view>
			</view>
		</view>

		<view class="u-p-t-38" v-if="list.length==0">
			<u-empty   text="暂无数据"></u-empty>
		</view>


		<u-popup v-model="search" mode="top" :z-index="20">
			<view style="padding-top:72px;" class=" u-m-l-24 u-m-r-24">
				<u-form :model="params" labelWidth="auto" >
					<u-form-item right-icon="arrow-right" label="提现时间">
						<u-input @click="date = true" input-align="right" v-model="params.beginMonth" disabled></u-input>
					</u-form-item>
				</u-form>
			</view>
		</u-popup>

		<!-- 日期选择 -->
		<u-picker v-model="date" mode="time"  :params="par" @confirm="timeConfirm"></u-picker>
	</view>
</template>

<script setup lang="ts">
	import enumIndex from '@/enum/index'
	import { onLoad,onReachBottom } from '@dcloudio/uni-app'
	import shopApi from '@/api/shop'
	import moment from 'moment'
	import { reactive, ref } from "vue";

	const list = ref([])

	const search = ref<boolean>(false)

	const date = ref<boolean>(false)

    const par = reactive({
		year: true,
		month: true
	})

	const params = reactive({
		pageNo: 1,
		pageSize: 10,
		beginMonth: moment().format('YYYY-MM')
	})

	const timeConfirm = (e) => {
		params.beginMonth = `${e.year}-${e.month}`
		getList('reset')
		search.value = false

	}

	function getList(type) {
		switch(type){
			case 'reset':
			  params.pageNo = 1
			  list.value = []
			break;
		}
		shopApi.cashRecordList(params).then(res => {
			if(list.value.length<res.data.total){
				list.value = list.value.concat(res.data.list)
				params.pageNo++

			}
		})
	}

	onReachBottom(()=>{
		getList('add')
	})

	onLoad(() => {
		getList('onload')
	})
</script>

<style lang="scss" scoped>
	.bottom{
	  border-top: 1rpx solid #f7f6f6;
	  width: 100%;
	  text-align: end;
	  font-size: 29rpx;
	  color: #787879;
	  padding-top:10rpx;
	  margin-top:10rpx;
	}
</style>
